import store from '@/store'

/**
 * 获取头像
 */
export function getAvatar () {
	var userInfo = uni.getStorageSync('userInfo');
	var avatarMan = store.state.user.avatarMan;
	var avatarWoman = store.state.user.avatarWoman;
	var avatar= userInfo.avatar?userInfo.avatar:(userInfo.gender==0?avatarWoman:avatarMan);
	return avatar;
}

/**
 * 对象深度克隆
 * */
export function clone(obj){
	if(obj === null) return null;
	if(typeof obj !== 'object') return obj;
	if(obj.constructor===Date) return new Date(obj);
	if(obj.constructor === RegExp) return new RegExp(obj);
	var newObj = new obj.constructor();  //保持继承链
	for (var key in obj) {
		if (obj.hasOwnProperty(key)) {   //不遍历其原型链上的属性
			var val = obj[key];
			newObj[key] = typeof val === 'object' ? clone(val) : val; // 使用arguments.callee解除与函数名的耦合
		}
	}
	return newObj;
}